package com.nengchuan.eic.nceconomy.controller;

import com.nengchuan.eic.nceconomy.service.RoleService;
import com.nsc.boot.sdk.common.msg.ApiResult;
import com.nsc.boot.sdk.role.model.vo.RoleUserVO;
import com.nsc.boot.sdk.role.model.vo.RoleVo;
import com.nsc.boot.sdk.role.model.vo.UserVo;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiParam;
import io.swagger.annotations.ApiResponse;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestParam;
import org.springframework.web.bind.annotation.RestController;

import java.util.List;

@RestController
@Api(tags = {"角色相关API"})
public class RoleController extends com.nsc.boot.sdk.role.controller.RoleController {

    @Autowired
    private RoleService roleService;

    @ApiResponse(code = 200, message = "成功为true,失败为false", response = ApiResult.class)
    @Override
    public ApiResult<List<RoleVo>> getRoles() {
        return ApiResult.success(roleService.findRoles(1));
    }

    @ApiResponse(code = 200, message = "成功为true,失败为false", response = ApiResult.class)
    @Override
    public ApiResult<List<RoleUserVO>> getRoleUsers() {
        return ApiResult.success(roleService.getRoleUsers());
    }

    @ApiResponse(code = 200, message = "成功为true,失败为false", response = ApiResult.class)
    @Override
    public ApiResult<List<UserVo>> getUsers(@RequestParam("ri") @ApiParam("角色ID") String roleId) {
        return ApiResult.success(roleService.getUsers(Long.valueOf(roleId)));
    }
}
